unit Calendario;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Buttons, Grids, Calendar, ExtCtrls;

type
  TfrmCalendario = class(TForm)
    Bevel1: TBevel;
    almanaque: TCalendar;
    btnAnt: TSpeedButton;
    lblMes: TLabel;
    btnSig: TSpeedButton;
    btnCancelar: TBitBtn;
    btnAceptar: TBitBtn;
    Panel64: TPanel;
    Panel63: TPanel;
    procedure btnAntClick(Sender: TObject);
    procedure btnSigClick(Sender: TObject);
    procedure almanaqueChange(Sender: TObject);
    procedure almanaqueDblClick(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    procedure EstablecerDia(Dia: TDateTime);
    function RecuperarDia: TDateTime;
  public
    property Dia: TDateTime read RecuperarDia write EstablecerDia;
  end;

var
  frmCalendario: TfrmCalendario;

implementation

uses Recursos;

{$R *.dfm}

procedure TfrmCalendario.EstablecerDia(Dia: TDateTime);
begin
  almanaque.CalendarDate := Dia;
end;

function TfrmCalendario.RecuperarDia: TDateTime;
begin
  Result := almanaque.CalendarDate;
end;

procedure TfrmCalendario.btnAntClick(Sender: TObject);
begin
  almanaque.PrevMonth;
end;

procedure TfrmCalendario.btnSigClick(Sender: TObject);
begin
  almanaque.NextMonth;
end;

procedure TfrmCalendario.almanaqueChange(Sender: TObject);
begin
  lblMes.Caption := FormatDateTime('MMMM, YYYY', almanaque.CalendarDate);
end;

procedure TfrmCalendario.almanaqueDblClick(Sender: TObject);
begin
  ModalResult := mrYes;
end;

procedure TfrmCalendario.FormCreate(Sender: TObject);
begin
  Acomodo(frmCalendario);
end;

end.
